<?php

namespace app\admin\model;

use app\common\model\TimeModel;

class AppGpuPrice extends TimeModel
{

    protected $name = "app_gpu_price";

    protected $deleteTime = "delete_time";


    public const SELECT_LIST_TYPE = ['0' => '显卡报价', '1' => '整机报价',];

    public const SELECT_LIST_STATUS = ['0' => '禁用', '1' => '启用',];

    protected $append = ['type_title'];


    public function appGpu()
    {
        return $this->belongsTo('\app\admin\model\AppGpu', 'gpu_id', 'id');
    }

    public function getTypeTitleAttr()
    {
        return $this::SELECT_LIST_TYPE[$this->getData('type')] ?? '';
    }

    public function getCostPriceAttr()
    {
        return $this->getData('price') / $this->getAttr('appGpu')->cuda_count;
    }
}
